<?php 
	FunctionsHelper::includeFiles(
		array(
			PUBLIC_CONTROLLERS_DIRECTORY . 'tournament_classes.php',
			PUBLIC_CONTROLLERS_DIRECTORY . 'tournaments.php'
		)
	);

	$arrClasses = array();

	$TournamentClasses = new tournament_classes();
	$classes = $TournamentClasses->getAllClasses();

	foreach ($classes as &$class){
		$class['description'] = str_replace(' ', '_', strtolower($class['description']));
		$arrClasses[$class['description']] = $class['class_id'];
	}


	$Tournaments = new tournaments();
	$GrandSlams = $Tournaments->getAllTournamentFromClass($arrClasses['grand_slam']);
	$NationalTournaments = $Tournaments->getAllTournamentFromClass($arrClasses['nations']);
	$MastersCup = $Tournaments->getAllTournamentFromClass($arrClasses['masters_cup']);
	
	foreach ($GRAND_SLAMS as $GrandSlam){
		if (!isset($GrandSlams[$GrandSlam]))
			$GrandSlams[$GrandSlam] = new Tournament(array('id' => 0));
	}

	foreach ($DAVIS_FED as $NationalTournament){
		if (!isset($NationalTournaments[$NationalTournament]))
			$NationalTournaments[$NationalTournament] = new Tournament(array('id' => 0));
	}
	
	if (!session_id()){
		session_start();
	}
	$currentPage = isset($_SESSION["currentPage"]) && !empty($_SESSION["currentPage"]) ? $_SESSION["currentPage"] : "home.php";
?>